import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class decisionTree {

	public class Node {

		// 特征名称
		public int FeatureName;
		// 此节点的分类子节点
		public ArrayList<Node> childrenNodeList = new ArrayList<Node>();
	}

	public static void main(String[] args) {

	}

	public Node dTree(String filePath) throws IOException {
		Node node = new Node();
		BufferedReader bReader = new BufferedReader(
				new InputStreamReader(new FileInputStream(new File(filePath)), "UTF-8"));
		String aLine = "";
		String[] ATTR = null;// 属性名称
		ATTR = bReader.readLine().split("\t");
		int xString, yString;
		Map<Integer, Integer> kind = new HashMap();// 存放样本及其类别
		ArrayList<Map<Integer, ArrayList<Map<Integer, Integer>>>> attribute_value = new ArrayList<>();// 存放样本的属性值
		while ((aLine = bReader.readLine()) != null) {
			String[] attribute = null;// 属性值
			attribute = aLine.split("\t");
			xString = Integer.parseInt(attribute[0]);
			yString = Integer.parseInt(attribute[attribute.length - 1]);
			kind.put(xString, yString);
			Map<Integer, Integer> map1 = new HashMap<>();
			Map<Integer, ArrayList<Map<Integer, Integer>>> map2 = new HashMap<>();
			ArrayList<Map<Integer, Integer>> list1 = new ArrayList<>();
			for (int i = 1; i < ATTR.length - 1; i++) {
				map1.put(Integer.parseInt(ATTR[i]), Integer.parseInt(attribute[i]));
				list1.add(map1);
			}
			map2.put(Integer.parseInt(attribute[0]), list1);
			attribute_value.add(map2);
		}
		int finalKind;
		finalKind = kind.get(0);
		// 如果D中样本全属于同一类别
		for (int i = 1; i < kind.size(); i++) {
			if (!(kind.get(i) == finalKind)) {
				break;
			} else {
				node.FeatureName = finalKind;
			}
		}

		return node;
	}
}
